<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>睡眠排序</title>
    <script>
        arr = []
        arr.length=5
        arr[0]=new Worker("./wk.js");
        arr[1]=new Worker("./wk.js");
        arr[2]=new Worker("./wk.js");
        arr[3]=new Worker("./wk.js");
        arr[4]=new Worker("./wk.js");

        const receiver = evnt => document.getElementById("res").innerText+=`${evnt.data} `
        
    </script>

</head>

<body>
    <span>请输入第1个（整数,100~1000）</span><br />
    <input name="dta" type="text"/><br />
    <span>请输入第2个（整数,100~1000）</span><br />
    <input name="dta" type="text"/><br />
    <span>请输入第3个（整数,100~1000）</span><br />
    <input name="dta" type="text"/><br />
    <span>请输入第4个（整数,100~1000）</span><br />
    <input name="dta" type="text"/><br />
    <span>请输入第5个（整数,100~1000）</span><br />
    <input name="dta" type="text"/><br />
    <button id="btn" onclick="getData()">排序</button><br />
    <span>结果</span><br />
    <span id="res"></span><br />
    <script>
        function getData() {
            val = document.getElementsByName("dta")
            console.log(val);
            document.getElementById("res").innerText="";
            for(let i = 0;i<5;i+=1){
                arr[i].onmessage=receiver;
            }
            for(let i = 0;i<5;i+=1){
                arr[i].postMessage(val[i].value);
            }
        }
    </script>
</body>

</html>